The R markdown is available from the pulldown menu for Code at the upper-right, choose “Download Rmd”, or download the Rmd from GitHub.
Probably the most common use of expression data in Cytoscape is to set the visual attributes of the nodes in a network according to expression data. This creates a powerful visualization, portraying functional relation and experimental response at the same time. Here, we will walk through the steps for doing this.
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
if(!"RCy3" %in% installed.packages())
BiocManager::install("RCy3")
install.packages("httr")First, launch Cytoscape and keep it running whenever using RCy3. Confirm that you have everything installed and running:
library(RCy3)
cytoscapePing()You are connected to Cytoscape!
cytoscapeVersionInfo() apiVersion cytoscapeVersion
"v1" "3.8.2"
library(httr)
cys_url = "http://nrnb.org/data/galFilteredSimpleData.cys"
GET(cys_url, write_disk(tf <- tempfile(fileext = ".cys")))Response [https://nrnb.org/data/galFilteredSimpleData.cys]
Date: 2021-01-16 21:25
Status: 200
Content-Type: application/octet-stream
Size: 1.4 MB
<ON DISK> C:\WINDOWS\TEMP\RtmpGS7eWA\file459478b7504e.cys
openSession(tf)Opening C:\WINDOWS\TEMP\RtmpGS7eWA\file459478b7504e.cys...
fitContent function:fitContent()getTableColumnNames('node') [1] "SUID" "shared name" "name" "selected" "COMMON" "gal1RGexp" "gal4RGexp" "gal80Rexp" "gal1RGsig" "gal4RGsig" "gal80Rsig"
setNodeLabelMapping('COMMON')style.name not specified, so updating "default" style.
NULL
gal80rexp.score.table <- getTableColumns('node', "gal80Rexp")
gal80rexp.min <- min(gal80rexp.score.table, na.rm = T)
gal80rexp.max <- max(gal80rexp.score.table, na.rm = T)
print(gal80rexp.min)[1] -1.373
print(gal80rexp.max)[1] 3.126
setNodeColorMapping("gal80Rexp", c(-gal80rexp.max, 0, gal80rexp.max), c('#0000FF', '#FFFFFF', '#FF0000'))style.name not specified, so updating "default" style.
NULL
Note that the default node color of pale blue is close to the color range in the created palette. A useful trick is to choose a color outside this spectrum to distinguish nodes with no defined expression value and those with slight repression.
setNodeColorDefault('#A9A9A9')style.name not specified, so updating "default" style.
fitContent()We imported both expression measurement values and corresponding significance values. We can use the significance values to change the border of nodes to highlight measurements we have confidence in.
Let’s create a thicker node border for nodes with gal80Rsig value less than 0.05. First, we need to get the min and max of values for gal80Rsig
gal80rsig.score.table <- getTableColumns('node', "gal80Rsig")
gal80rsig.min <- min(gal80rsig.score.table, na.rm = T)
gal80rsig.max <- max(gal80rsig.score.table, na.rm = T)
print(gal80rsig.min)[1] 1.7403e-20
print(gal80rsig.max)[1] 0.999999
setNodeBorderWidthMapping('gal80Rsig', c(gal80rsig.min, "0.0499999", "0.05", gal80rsig.max), c('10',"10",'0', '0'))style.name not specified, so updating "default" style.
NULL
The node border now indicates significance, but since the default node border color is a pale grey, it is not very visible. We can change the default border color to a darker grey:
setNodeBorderColorDefault('#666666')style.name not specified, so updating "default" style.
In addition to coloring the nodes, Cytoscape also provides the ability to draw charts and graphs on each node. For example, suppose we wanted to display a bar chart showing all of the expression values on each of our nodes?
getVisualPropertyNames() [1] "COMPOUND_NODE_PADDING" "COMPOUND_NODE_SHAPE" "DING_RENDERING_ENGINE_ROOT" "EDGE"
[5] "EDGE_BEND" "EDGE_CURVED" "EDGE_LABEL" "EDGE_LABEL_COLOR"
[9] "EDGE_LABEL_FONT_FACE" "EDGE_LABEL_FONT_SIZE" "EDGE_LABEL_TRANSPARENCY" "EDGE_LABEL_WIDTH"
[13] "EDGE_LINE_TYPE" "EDGE_PAINT" "EDGE_SELECTED" "EDGE_SELECTED_PAINT"
[17] "EDGE_SOURCE_ARROW_SELECTED_PAINT" "EDGE_SOURCE_ARROW_SHAPE" "EDGE_SOURCE_ARROW_SIZE" "EDGE_SOURCE_ARROW_UNSELECTED_PAINT"
[21] "EDGE_STROKE_SELECTED_PAINT" "EDGE_STROKE_UNSELECTED_PAINT" "EDGE_TARGET_ARROW_SELECTED_PAINT" "EDGE_TARGET_ARROW_SHAPE"
[25] "EDGE_TARGET_ARROW_SIZE" "EDGE_TARGET_ARROW_UNSELECTED_PAINT" "EDGE_TOOLTIP" "EDGE_TRANSPARENCY"
[29] "EDGE_UNSELECTED_PAINT" "EDGE_VISIBLE" "EDGE_WIDTH" "NETWORK"
[33] "NETWORK_ANNOTATION_SELECTION" "NETWORK_BACKGROUND_PAINT" "NETWORK_CENTER_X_LOCATION" "NETWORK_CENTER_Y_LOCATION"
[37] "NETWORK_CENTER_Z_LOCATION" "NETWORK_DEPTH" "NETWORK_EDGE_SELECTION" "NETWORK_FORCE_HIGH_DETAIL"
[41] "NETWORK_HEIGHT" "NETWORK_NODE_LABEL_SELECTION" "NETWORK_NODE_SELECTION" "NETWORK_SCALE_FACTOR"
[45] "NETWORK_SIZE" "NETWORK_TITLE" "NETWORK_WIDTH" "NODE"
[49] "NODE_BORDER_PAINT" "NODE_BORDER_STROKE" "NODE_BORDER_TRANSPARENCY" "NODE_BORDER_WIDTH"
[53] "NODE_CUSTOMGRAPHICS_1" "NODE_CUSTOMGRAPHICS_2" "NODE_CUSTOMGRAPHICS_3" "NODE_CUSTOMGRAPHICS_4"
[57] "NODE_CUSTOMGRAPHICS_5" "NODE_CUSTOMGRAPHICS_6" "NODE_CUSTOMGRAPHICS_7" "NODE_CUSTOMGRAPHICS_8"
[61] "NODE_CUSTOMGRAPHICS_9" "NODE_CUSTOMGRAPHICS_POSITION_1" "NODE_CUSTOMGRAPHICS_POSITION_2" "NODE_CUSTOMGRAPHICS_POSITION_3"
[65] "NODE_CUSTOMGRAPHICS_POSITION_4" "NODE_CUSTOMGRAPHICS_POSITION_5" "NODE_CUSTOMGRAPHICS_POSITION_6" "NODE_CUSTOMGRAPHICS_POSITION_7"
[69] "NODE_CUSTOMGRAPHICS_POSITION_8" "NODE_CUSTOMGRAPHICS_POSITION_9" "NODE_CUSTOMGRAPHICS_SIZE_1" "NODE_CUSTOMGRAPHICS_SIZE_2"
[73] "NODE_CUSTOMGRAPHICS_SIZE_3" "NODE_CUSTOMGRAPHICS_SIZE_4" "NODE_CUSTOMGRAPHICS_SIZE_5" "NODE_CUSTOMGRAPHICS_SIZE_6"
[77] "NODE_CUSTOMGRAPHICS_SIZE_7" "NODE_CUSTOMGRAPHICS_SIZE_8" "NODE_CUSTOMGRAPHICS_SIZE_9" "NODE_CUSTOMPAINT_1"
[81] "NODE_CUSTOMPAINT_2" "NODE_CUSTOMPAINT_3" "NODE_CUSTOMPAINT_4" "NODE_CUSTOMPAINT_5"
[85] "NODE_CUSTOMPAINT_6" "NODE_CUSTOMPAINT_7" "NODE_CUSTOMPAINT_8" "NODE_CUSTOMPAINT_9"
[89] "NODE_DEPTH" "NODE_FILL_COLOR" "NODE_HEIGHT" "NODE_LABEL"
[93] "NODE_LABEL_COLOR" "NODE_LABEL_FONT_FACE" "NODE_LABEL_FONT_SIZE" "NODE_LABEL_POSITION"
[97] "NODE_LABEL_TRANSPARENCY" "NODE_LABEL_WIDTH" "NODE_NESTED_NETWORK_IMAGE_VISIBLE" "NODE_PAINT"
[101] "NODE_SELECTED" "NODE_SELECTED_PAINT" "NODE_SHAPE" "NODE_SIZE"
[105] "NODE_TOOLTIP" "NODE_TRANSPARENCY" "NODE_VISIBLE" "NODE_WIDTH"
[109] "NODE_X_LOCATION" "NODE_Y_LOCATION" "NODE_Z_LOCATION"
deleteStyleMapping("default", "NODE_FILL_COLOR")setNodeColorDefault('#D3D3D3')style.name not specified, so updating "default" style.
setNodeCustomBarChart(c("gal1RGexp", "gal4RGexp", "gal80Rexp"), "HEAT_STRIPS")style.name not specified, so updating "default" style.
The network now shows heat strips for the three expression values, with colors chosen from a default Brewer palette.